package main;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import javax.imageio.ImageIO;
import javax.swing.*;

import jobs.Reaper;

//import jobs.Reaper;
import spells.Fireball;
import spells.Heal;
import spells.Ignite;
import spells.PainSpike;
import spells.Replenish;
import creatures.Wolf;

public class IntroStart extends JFrame implements ActionListener {
	Grid currentGrid;
	TestingPanel currentPanel;
	JFrame chooser;
	
	static Player you;
	static ArrayList<Creature> enemies;
	static String tile;
	Object object;
	int i;
	Enemy enemy;
	
	static IntroChooserPanel choice;
	
	JButton newGame = new JButton("New Game");
	JButton loadGame = new JButton("Load Game");
	JButton options = new JButton("Options");
	JButton exitGame = new JButton("Exit");

	public IntroStart () {
		//Initialize
		enemies=new ArrayList<Creature>();
		enemies.add(new Wolf(5,3,"Wolf 1"));
		enemies.get(0).x=5;
		enemies.get(0).y=3;
		
		enemies.add(new Wolf(2,8,"Wolf 2"));
		enemies.get(1).x=2;
		enemies.get(1).y=8;
		
		enemies.add(new Wolf(6,9,"Wolf 3"));
		enemies.get(2).x=6;
		enemies.get(2).y=9;
		
		tile="tiles/dirt.jpg"/*"grass.gif"*/;
		//End of Initialize
		
		Dimension d = new Dimension (824,646);
		this.setSize(d);
		this.setLayout(new FlowLayout());
		currentPanel = new TestingPanel();
		
		File background = new File("HeroesQuestBanner.jpg");
		BufferedImage background1 = null;
		try {
			background1 = ImageIO.read(background);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		ImageIcon background2 = new ImageIcon(background1);
		JLabel background3 = new JLabel();
		background3.setMinimumSize(d);
		background3.setIcon(background2);
		currentPanel.add(background3);
		
		newGame.addActionListener(this);
		loadGame.addActionListener(this);
		options.addActionListener(this);
		exitGame.addActionListener(this);
		
		add(newGame);
		add(loadGame);
		add(options);
		add(exitGame);
		
		add(currentPanel);
		
		this.setVisible(true);
		this.setResizable(false);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
	}

	public static void launch() {
		/*you=new Player(1,2,choice.getName(),choice.getJob());
		//you.curHealth = 100;
		//you.maxHealth = 100;
		//you.strength = 10;
		you.addSpell(new Fireball(you));
		you.addSpell(new Heal(you));
		you.addSpell(new Ignite(you));
		you.addSpell(new Replenish(you));
		you.addSpell(new PainSpike(you));
		you.level = 1;
		//you.armor = 0;
		you.x=1;
		you.y=2;
		
		//IntroWindow intro = new IntroWindow();
		//BattleGrid test=new BattleGrid(you,enemies,tile,null, 3, (Enemy)enemies.get(0),1);
	*/
		Player you=new Player(1,2,"Hero",new Reaper());
		you.curHealth = 100;
		you.maxHealth = 100;
		you.strength = 10;
		you.addSpell(new Fireball(you));
		you.addSpell(new Heal(you));
		you.addSpell(new PainSpike(you));
		you.addSpell(new Ignite(you));
		Weapon dagger = new Weapon();
		dagger.damage = 5;
		dagger.attackSpeed = 0.5;
		you.weapon1 = dagger;
		you.level = 1;
		you.armor = 0;
		you.x=1;
		you.y=2;
		
		
		GameGrids g=new GameGrids(you);
		
		//BattleGrid test=new BattleGrid(you,enemies,tile,null, 1);
		BattleGridTest test=new BattleGridTest(you,g,0);
	}
	
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == newGame){
			choice = new IntroChooserPanel();
			this.setVisible(false);
		}
		else if (e.getSource() == loadGame) {
			
			this.setVisible(false);
		}
		else if (e.getSource() == options) {
			
			this.setVisible(false);
		}
		else if (e.getSource() == exitGame) {
			this.setVisible(false);
			System.exit(0);
		}
	}
	
	public static void main(String[] args) throws IOException {
		IntroStart t = new IntroStart();
	}
	
	public class TestingPanel extends JPanel  {
		public TestingPanel(){
		
		}
	}
}